﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace MLM.AdminCP.Class
{
    public static class Message
    {
        /// <summary>
        /// Show Success
        /// </summary>
        public static void ShowSuccess()
        {
            ShowSuccess("Save Done!");
        }
        public static void ShowSuccess(string content)
        {
            content = content.Replace("'", "&quote;").Replace("\"", "&quote;");
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "NotifySuccess",
                                                            "MLMShowSuccessMessage('" + content + "');", true);                
            }           
        }
        /// <summary>
        /// Show Error
        /// </summary>
        public static void ShowError()
        {
            ShowError("Error Occurred!");
        }
        public static void ShowError(string content)
        {
            content = content.Replace("'", "&quote;").Replace("\"", "&quote;");
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "NotifyError",
                                                            "MLMShowErrorMessage('" + content + "');", true);
            }
        }
        /// <summary>
        /// Show Alert
        /// </summary>
        /// <param name="content"></param>
        public static void ShowAlert(string content)
        {
            content = content.Replace("'", "&quote;").Replace("\"", "&quote;");
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "NotifyAlert",
                                                            "MLMShowAlertMessage('" + content + "');", true);
            }
        }
        /// <summary>
        /// Show Message
        /// </summary>
        /// <param name="content"></param>
        public static void ShowMessage(string content)
        {
            content = content.Replace("'", "&quote;").Replace("\"", "&quote;");
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "NotifyMessage",
                                                            "MLMShowNormalMessage('" + content + "');", true);
            }
        }

    }
}